package com.aiyige.page.filter.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.filter.model.Order;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderAdapter extends BaseQuickAdapter<Order, OrderAdapter.ViewHolder> {

    public OrderAdapter() {
        super(R.layout.order_item, new LinkedList<Order>());
    }

    @Override
    protected void convert(ViewHolder helper, Order item) {
        helper.bindData(item);
    }


    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.selectedIv)
        ImageView selectedIv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(Order order) {
            if (order.isSelected()) {
                titleTv.setText(order.getTitle());
                titleTv.setSelected(true);
                selectedIv.setVisibility(View.VISIBLE);
            } else {
                titleTv.setText(order.getTitle());
                titleTv.setSelected(false);
                selectedIv.setVisibility(View.INVISIBLE);
            }
        }
    }

}
